Repository navigation
feat(cloudflare): playground Worker and PlaygroundSite Durable Object (RFC-0036 phase 3) - #24
Merged
Merged
Conversation
RFC-0036 phase 3. @cloudhal/cloudflare/playground: createPlaygroundWorker returns the Worker and the PlaygroundSite class. Each session is one SQLite-backed Durable Object holding the store (DoSqliteDriver, SQL blobs over read-only demo media), the API in playground mode and the rendered site under /s/<session>/ (private, no-store, noindex, links kept under the prefix). The object seeds on first use, sets a 60-minute alarm capped at 2 hours, wipes on Reset and refuses requests past the cap. The Worker issues the host-only session cookie, applies isBlockedInPlayground, body, rate and node/database limits, Turnstile after a limit hit, a daily cap and the kill switch. The cookie carries an HMAC of the ULID: unsigned, a client could mint sessions past every creation limit. RFC-0036 gains implementation notes for this and the other differences, ADR-0038 an amendment. @cloudhal/astro-renderer/runtime gains withRequestStore, which renders a request from a store the entry chooses. Tested on workerd: open, edit, publish, render, reset, refuse past the cap, 20 sessions at once. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Madraka <[email protected]>
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
Merged
Madraka
added a commit
that referenced
this pull request
Oct 20, 2026
feat(cloudflare): playground Worker and PlaygroundSite Durable Object (RFC-0036 phase 3)
Madraka
added a commit
that referenced
this pull request
Oct 20, 2026
The public playground (RFC-0036): Durable Object SQLite storage (#22), playground mode in the API and Studio (#23), and the playground Worker and PlaygroundSite Durable Object (#24). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Madraka <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RFC-0036 phase 3. Stacked: this branch contains #10 (RFC acceptance), #22 (phase 1) and #23 (phase 2) as merges; the phase-3 change is the last commit (a28c22e). Merge after those three; the diff then shrinks to that commit.
@cloudhal/cloudflare/playgroundcreatePlaygroundWorker({ seed, render, deployUrl, demoMedia, limits, landingPath })→{ worker, PlaygroundSite }.POST /_playground/session(signed__Host-cloudhal_trycookie, 303 →/sites),POST /_playground/reset, guard (isBlockedInPlayground) before forwarding, 1 MB request cap,SESSION_LIMITper IP (Turnstile only after a hit),WRITE_LIMITper session,PLAYGROUND_DAILY_SESSIONS(counter objectdaily:<date>),PLAYGROUND_ENABLED=falsekill switch,/= landing without a session, Studio with one.PlaygroundSite(SQLite DO):DoSqliteDriver+SiteGraphStore+LayeredBlobStore(FetcherBlobStore(ASSETS, demo), SqlBlobStore 8 MiB), seeded once underblockConcurrencyWhile;createApi({ playground }); alarm atmin(last + 60 min, created + 120 min); Reset/alarm →deleteAll; past the cap → 410 even without the alarm; 507 when the database passes 20 MB or 500 nodes;/s/<session>/…and/media/*through the deployer'srender, made private (private, no-store,noindex, nocache-tag, links rewritten under the prefix).@cloudhal/astro-renderer/runtime:withRequestStore(store, siteId, fn)(AsyncLocalStorage; private headers for such pages).RFC/ADR changes (RFC-0036 "Implementation notes", ADR-0038 amendment): the session cookie is signed (HMAC,
PLAYGROUND_SECRET) — unsigned, a client could mint sessions and skip the creation limits and daily cap; Studio at the root, not/studio/*; guard answersschedules/unclassified; principal details; entry API shape; blob-store details; measured numbers.Tests:
test/playground.test.ts(sessions, prefixes, routing, kill switch, Turnstile) andtest/playground-workerd.test.tson workerd via wrangler's harness: open → edit → publish → render, reset reseeds, refused past the cap (Worker and object), 20 sessions at once in 0.44 s. Real Astro rendering is verified in thetryrepo withwrangler dev(phase 4).pnpm checkgreen locally (run alone, 18/18 tasks).🤖 Generated with Claude Code